package com.jishuo.nontax.view.controller;

import com.jishuo.base.bean.BaseResult;
import com.jishuo.base.bean.GridResult;
import com.jishuo.base.bean.Pagination;
import com.jishuo.base.bean.vo.UserVO;
import com.jishuo.base.util.GTimeUtil;
import com.jishuo.nontax.bean.vo.BackpaybillVO;
import com.jishuo.nontax.bfc.service.BackBillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * 退付书
 */
@Slf4j
@Controller
@RequestMapping(value = "/view/backpaybill", name = "退付书")
public class BackPayBillViewController {

    @Resource
    private BackBillService backBillService;

    // 页面文件位置
    private String prefix = "view/";

    @RequestMapping(value = {"backbillview"}, name = "退付书首页")
    public String index() {
        return prefix + "backbillview";
    }

    /**
     * @author hlp
     * @date 2023/3/7 17:42
     * @Description: 退付书列表
     */
    @ResponseBody
    @RequestMapping(value = "findBackPayBillPage", name = "退付书列表")
    public GridResult<BackpaybillVO> findBackPayBillPage(BackpaybillVO backpaybillVO , Pagination pagination) {
        return new GridResult<>(backBillService.findBackPayBillPage(backpaybillVO,pagination));
    }

    /**
     * @author hlp
     * @date 2023/3/29 11:01
     * @Description: 退付书查询单据
     */
    @ResponseBody
    @RequestMapping(value="queryBackBillData")
    public BaseResult queryBackBillData(String backbillnum) {
        return backBillService.getBackbill(backbillnum);
    }

    @ResponseBody
    @RequestMapping(value="/backbillpayview")
    public BaseResult backbillpayview(BackpaybillVO backpaybillVO, HttpSession session) {
        UserVO user = (UserVO) session.getAttribute("login_user");
        backpaybillVO.setBankstation(user.getBankStationName());
        backpaybillVO.setDealdate(GTimeUtil.getDateTimeMark());
        BaseResult baseResult = backBillService.setBackBillDeposit(backpaybillVO, "");
        return baseResult;
    }

}
